package system.base;

import java.util.Map;

import framework.core.*;
import system.SelectManager;
import system.data.*;

/*
	Author    :Arrow
	CreateTime:2009-01-05 10:28:05
*/
public class WorldExp extends WorldExpBase 
{

//----system generated start----// 	
public WorldExp() 
{
	
}

private static void delete(DBConnection con,String id) throws Exception
{
	Conditions conditions = new Conditions();

	conditions.add(ID,id);
	
	delete(con,TABLE_NAME,conditions);
}
public static WorldExp fetch()
{
	return new WorldExp();
}
public static WorldExp copy(WorldExp srcObj)
{
	WorldExp obj = fetch();
	obj.copyBase(srcObj);
	return obj;
}
public static WorldExp fetch(DBConnection con,String id) throws Exception
{
	Conditions conditions = new Conditions();

	conditions.add(ID,id);
	
	return fetch(con,conditions);
}
public static WorldExp fetch(DBConnection con,Conditions conditions) throws Exception
{
	DBResult result = null;
	try
	{
		result = DBEngine.doSelect(con,"select * from " + TABLE_NAME,conditions);
		java.sql.ResultSet rs = result.getRs();
		WorldExp obj = null;
		if(rs.next())
		{
			obj = fetch(rs);
		}
		return obj;
	}
	finally
	{
		if(result!=null) result.clear() ;
	}
}
public static WorldExp fetch(java.sql.ResultSet rs) throws Exception
{
	WorldExp obj = new WorldExp();
	obj.initObject(rs);
	return obj;
}
protected void getUnique(DBConnection con) throws Exception
{
		setId(DBEngine.getId(con));
}
//----system generated end----//



//----add by Arrow start----//
public static String getBillTypeCode(String title) throws Exception
{
    String code = "";
    Map type = ConstDefine.initWorldExpCode();
    for(int i = 0; i < ConstDefine.BILL_TYPE_CODE.length; i++)
    {
        String key = ConstDefine.BILL_TYPE_CODE[i];
        String content = (String)type.get(key);
        if(title.startsWith(content))
        {
            code = key;
            break;
        }
    }
    
    return code;
}

public static String getBillType(String key) throws Exception
{
    Map type = ConstDefine.initWorldExpCode();
    String typeName = (String)type.get(key);
    if(typeName == null) typeName = "";
    
    return typeName;
}

public static String getWarehouseJTCode(String warehouseName) throws Exception
{
    String code = "";
    Map type = ConstDefine.initWorldExpWarehouse();
    for(int i = 0; i < ConstDefine.WAREHOUSE_JT_CODE.length; i++)
    {
        String key = ConstDefine.WAREHOUSE_JT_CODE[i];
        String content = (String)type.get(key);
        if(content.equals(warehouseName))
        {
            code = key;
            break;
        }
    }
    
    return code;
}

public static String getWarehouseJTName(String key) throws Exception
{
    Map type = ConstDefine.initWorldExpWarehouse();
    String name = (String)type.get(key);
    if(name == null) name = "";
    
    return name;
}

public static String getBusType(String key) throws Exception
{
    Map type = ConstDefine.initWorldExpBusType();
    String name = (String)type.get(key);
    if(name == null) name = "";
    
    return name;
}

public static String changeWarehouseJTCode(String warehouseCode) throws Exception{
    String ret = "";
    if(warehouseCode == null) return ret;
    if("".equals(warehouseCode.trim())) return ret;
    
    if("00".equals(warehouseCode)){ //总库
        ret += "00";
    }
    if("0000".equals(warehouseCode)){ //总库
        ret += "00";
    }
    else if("000002".equals(warehouseCode)){ //一汽
        ret += "02";
    }
    else if("00000200".equals(warehouseCode)){ //一汽
        ret += "02";
    }
    else if("000001".equals(warehouseCode)){ //巴士新新
        ret += "01";
    }
    else if("00000100".equals(warehouseCode)){ //巴士新新
        ret += "01";
    }
    else if("00000101".equals(warehouseCode)){ //巴士新新
        ret += "01";
    }
    else if("00000102".equals(warehouseCode)){ //巴士新新
        ret += "01";
    }
    else if("000004".equals(warehouseCode)){ //电车公司
        ret += "04";
    }
    else if("00000400".equals(warehouseCode)){ //电车公司
        ret += "04";
    }
    else if("0000040000".equals(warehouseCode)){ //电车公司
        ret += "04";
    }
    else if("0000040001".equals(warehouseCode)){ //电车公司
        ret += "04";
    }
    else if("00000401".equals(warehouseCode)){ //电车公司
        ret += "04";
    }
    else if("0000040100".equals(warehouseCode)){ //电车公司
        ret += "04";
    }
    else if("000006".equals(warehouseCode)){ //宝山
        ret += "06";
    }
    else if("00000600".equals(warehouseCode)){ //宝山
        ret += "06";
    }
    else if("000003".equals(warehouseCode)){ //巴士四汽
        ret += "03";
    }
    else if("000005".equals(warehouseCode)){ //浦东
        ret += "05";
    }
    else if("000007".equals(warehouseCode)){ //上南
        ret += "07";
    }
    else if("000008".equals(warehouseCode)){ //高联
        ret += "08";
    }
    else if("000009".equals(warehouseCode)){ //大众西南
        ret += "09";
    }
    else if("000010".equals(warehouseCode)){ //大众西北
        ret += "10";
    }
    else if("000011".equals(warehouseCode)){ //大众巴士
        ret += "11";
    }
    else if("000012".equals(warehouseCode)){ //大众百通
        ret += "12";
    }
    else if("000013".equals(warehouseCode)){ //崇明大众
        ret += "13";
    }
    else if("000014".equals(warehouseCode)){ //申新巴士
        ret += "14";
    }
    else if("000015".equals(warehouseCode)){ //金山大众
        ret += "15";
    }
    else if("000016".equals(warehouseCode)){ //奉贤大众
        ret += "16";
    }
    else if("000017".equals(warehouseCode)){ //五汽公交
        ret += "17";
    }
    else if("000018".equals(warehouseCode)){ //强生公交
        ret += "18";
    }
   
    return ret;
}

/* (non-Javadoc)
 * @see system.data.WorldExpBase#viewFilePath(framework.core.DBConnection)
 */
public String viewFilePath(DBConnection aCon) throws Exception {
    String ret = super.viewFilePath(aCon);
    ret = StringUtil.replace(ret, "\\", "/");
    
    return ret;
}



//----add by Arrow end----//

}

